package com.dream.keigezhushou.Activity.acty.ksong;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dream.keigezhushou.Activity.activity.BaseActivity;
import com.dream.keigezhushou.Activity.view.NestedScrollViewBottom;
import com.dream.keigezhushou.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class KsongInfoActivity extends BaseActivity implements View.OnClickListener {

    @BindView(R.id.iv_return)
    ImageView ivReturn;
    @BindView(R.id.tv_song_name)
    TextView tvSongName;
    @BindView(R.id.tv_lrc)
    TextView tvLrc;
    @BindView(R.id.rl_choose_red)
    RelativeLayout rlChooseRed;
    @BindView(R.id.rl_choose_blue)
    RelativeLayout rlChooseBlue;
    @BindView(R.id.scroll_bottom)
    NestedScrollViewBottom scrollBottom;
    private Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ksong_info);
        ButterKnife.bind(this);

        initView();
        initData();
    }


    //初始化界面
    protected void initView() {

        //设置textview文本为两种颜色
        SpannableStringBuilder builder = new SpannableStringBuilder(tvLrc.getText().toString());
//        SpannableString builder = new SpannableString(tvLrc.getText());
        ForegroundColorSpan redSpan = new ForegroundColorSpan(Color.RED);
        ForegroundColorSpan buleSpan = new ForegroundColorSpan(Color.BLUE);


        builder.setSpan(redSpan,0,119, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//        builder.setSpan(buleSpan,59,119,Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
//        builder.setSpan(redSpan,119,188,Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        builder.setSpan(buleSpan,119,248,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

//        builder.setSpan(redSpan, 0, 59, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//        builder.setSpan(buleSpan, 59, 119, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//        builder.setSpan(redSpan, 119, 188, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
//        builder.setSpan(buleSpan, 188, 248, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

        tvLrc.setText(builder);
    }

    //初始化数据
    protected void initData() {

        rlChooseRed.setOnClickListener(this);
        rlChooseBlue.setOnClickListener(this);
        ivReturn.setOnClickListener(this);

        //滑动的监听
        scrollBottom.setScrollBottomListener(new NestedScrollViewBottom.ScrollBottomListener() {
            @Override
            public void scrollBottom() {

            }
        });
    }


    //点击事件的实现


    @Override
    public void onClick(View view) {


        switch (view.getId()) {


            case R.id.iv_return:

                finish();
                break;

            case R.id.rl_choose_red:

                intent = new Intent(this, ChorusInfoActivity.class);
                startActivity(intent);
                break;

            case R.id.rl_choose_blue:

                intent = new Intent(this, ChorusInfoActivity.class);
                startActivity(intent);
                break;
        }
    }
}
